﻿// See https://aka.ms/new-console-template for more information
using System;
namespace Calculate
{
    class Calculate
    {
        public static void Main(string[] args)
        {
            string s;
            string op;
            bool flag = true;
            double a;
            double b;
            double c = 0;
            Console.WriteLine("请输入第一个计算值 :");
            s = Console.ReadLine();
            a = double.Parse(s);
            Console.WriteLine("请输入操作符 :");
            op = Console.ReadLine();
            Console.WriteLine("请输入第二个计算值 :");
            s = Console.ReadLine();
            b = double.Parse(s);
            switch (op)
            {
                case "+":
                    c = a + b;
                    break;
                case "-":
                    c = a - b;
                    break;
                case "*":
                    c = a * b;
                    break;
                case "/":
                    if (b == 0)
                        flag = false;
                    else
                        c = a / b;
                    break;
                case "%":
                    if (b == 0)
                        flag = false;
                    else
                        c = a % b;
                    break;
                default:
                    flag = false;
                    break;
            }
            if (flag)
                Console.WriteLine("结果为 ：{0} {1} {2} = {3}", a, op, b, c);
            else
                Console.WriteLine("输入有误!");
        }
    }
}
